package com.gandong8.trace.tool.config.kafka.custom;

import com.gandong8.trace.tool.consumer.kafka.custom.TopicOneListener;
import com.gandong8.trace.tool.config.kafka.KafkaConsumerConf;
import com.gandong8.trace.tool.config.kafka.properties.custom.TopicOneProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.listener.KafkaMessageListenerContainer;

@Configuration
@EnableConfigurationProperties( TopicOneProperties.class)
@Slf4j
public class KafkaConsumerOneConf extends KafkaConsumerConf {
    @Autowired
    TopicOneProperties myConf;

    @Bean(name="kafkaTopicOneListener", initMethod = "start", destroyMethod = "stop")
    public KafkaMessageListenerContainer createConsumer() {
        TopicOneListener listener = new TopicOneListener();
        return super.createConsumer(myConf, listener);
    }
}
